Skip to content

Runs finish or hand back only for a listed reason: one supervisor for every ending - #635

Merged
nambok merged 1 commit into
mainfrom
runs-finish-or-hand-back-for-a-listed-reason
Nov 12, 2026
Merged

nambok merged 1 commit into
mainfrom
runs-finish-or-hand-back-for-a-listed-reason

Conversation

@nambok

@nambok nambok commented Nov 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Runs kept ending by handing unfinished work to a person: two steps that changed nothing stopped the run with a held draft, a CI fix that met the same failure set needs_input, own-review rounds at their cap asked a person to finish, an error after the work became a held draft with "a person should look". Each loop (implement steps, CI fix, own review, planned-work rounds, run guard, ready decision, the error arm) had its own stall rule and its own hand-back ending, and each earlier fix changed one of them, so the class kept coming back.

This makes the class structural:

  • needs_input can only be written with a HandBack, and a HandBack exists only for a reason on the human-only list (credential, missing access, product decision, ambiguous ticket, someone else holding the work, usage limit, approval, a person's own action). The compiler enforces it: the one function that writes the status takes one.
  • Every ending that used to hand back now finishes: it ships what is done with the rest deferred and explained, or reverts what broke CI and lets CI decide again, or (only when nothing can ship) ends failed with the exact cause. None of them waits on a person.
  • A stall changes approach instead of stopping the run.

Changes

  • common::handback (new): HumanOnly, HUMAN_ONLY, HandBack (private fields), HandBack::of_judged, human_only_in.
  • run_wait::NeedsInput::needs_input takes &HandBack and records its reason on the wait (waiting_on.handback). Every caller now supplies one: the ticket-question stops name what they ask for, the policy approval is Approval, a reopened run is PersonAction.
  • passes::supervisor (new): hand_back_for (the one reading of a stop), decide_end / end (the ending rule, with its rules checked), the stall ladder (next_rung: narrow, fresh context with edits in place, re-split, strongest model, defer, ship; non-core tasks such as readme lines defer after three), may_extend (rounds past a cap while they fix things, up to twice the cap), near_spend_cap (ship at 85% of the spend ceiling), revert_for.
  • Implement step (passes/mod.rs): a step that changed nothing climbs the ladder instead of returning the stall as an error; Defer and Ship write (deferred: ...) on the run's checklist (plan_coverage::with_deferred), which every later check reads as settled; Escalate uses the strongest implement model.
  • Error arm: an error after the work that names nothing human-only gets one fresh step; the step-limit continuation now covers every pass after the work started, not only implement.
  • stop_pr::open_with: a stop that isn't human-only ships (stop_pr::ship): remaining tasks deferred, the pull request opens or is updated with a "Deferred" section (no "Not finished, what you can do"), the run goes to awaiting_ci so the CI fix loop and the ready decision take it like any finished run.
  • resume::hand_off_red_ci (all five CI give-up sites): revert_to_green first: back to the newest green head of the pull request, else the last planned task back to the base branch, deferred and named on the pull request, up to three reverts; CI decides again.
  • resume::wait_on_person (own-review stop, planned-work stop, red-CI completion): completed with what is open listed, or failed with what fails when CI is red; waits only with a HandBack.
  • run_guard: a guard stop with an open pull request finishes it (finish_open_pr); with nothing to open, the run ends failed with the guard's reason.
  • ready: a hold on a finished run stays recorded and named on the pull request; the run turns into a wait only when a person put the pull request back to draft or the reason is on the list.
  • own_review::next: rounds extend past the cap while a round fixed something; the cap message no longer says "handed to a person".
  • agent/anthropic.rs: one rule for a turn cut at the output limit before any tool call, unified with Security update runs: planned by rule, verified in the sandbox, never stuck #634's nudge (continue_after_cut and the thinking-only retry are now cut_before_acting). It is taken again with one step less thinking and the output-limit note (act now, small edit_file calls), up to three times, instead of being read as the final answer. A reply that only thought is dropped (its cut thinking can't be signed and an assistant turn with no text or call can't be sent back; dropping the last turn leaves earlier thinking blocks round-tripping) and the note goes on the last user turn; a reply that said something stays in history with the note after it. The log records it as output_limit (NoteKind::OutputLimit).
  • Security dependency runs (Security update runs: planned by rule, verified in the sandbox, never stuck #634): at the stall limit they still go straight on to verify with what the branch holds instead of climbing the ladder; the supervisor takes its Ship rung for them at once, so the tasks left are deferred on the checklist with their reason.

Verification

  • cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace: pass.
  • supervisor::tests::every_ending_keeps_the_rules: all 64 combinations of open tasks, failing/running CI, blocker, work and ladder state keep the rules (no wait without a listed reason, nothing finished with failing checks or undeferred tasks).
  • supervisor::tests::across_the_replays_only_human_only_blockers_wait: 217 historical stuck-run shapes (invented names, how many tasks done, what stopped them). Through the old outcome rule 214 needed a person. Through the new rules, assuming no further attempt lands: 25 finish, 148 end failed with the cause (nothing to ship), 44 wait, every one on a need from the human-only list. Every run that had more than one task done and stopped on something CoderHelm owns finishes.
  • supervisor::tests::the_four_named_runs_finish_now: a security run stuck on a readme task after 8 of 9, a finished run whose pull request GitHub refused, a run stuck after 7 of 8, a CI fix that gave up after one try.
  • supervisor::tests::no_ending_goes_around_the_supervisor (source scan): fails when a file outside the ending sites writes needs_input, when a HandBack is made from anything but a listed reason, when a stall returns as an error again, when hand_off_red_ci gives up before reverting, or when an ending site stops reading the supervisor. It fails on the code before this change.
  • common::handback tests: stalls, red checks, time limits, budgets, tool errors and a too-long body are never read as human-only; access and credential words are.
  • anthropic::tests::a_turn_cut_before_any_call_is_taken_again_not_read_as_the_answer, plan_coverage::tests::a_deferred_task_is_settled_and_listed_with_why, stop_pr::tests::a_run_stopped_mid_work_ships_with_the_rest_deferred, own_review::tests::rounds_go_on_past_the_cap_while_they_fix_things_then_defer_the_rest.

… every ending

Runs kept ending by handing unfinished work to a person: two steps that
changed nothing stopped the run with a held draft, a CI fix that met the
same failure set needs_input, own-review rounds at their cap asked a
person, an error after the work became a held draft. Each loop had its own
stall rule and its own hand-back ending, and every earlier fix changed one
of them.

needs_input is now written only with a HandBack (common::handback), which
exists only for a reason on the human-only list: a credential, missing
access, a product decision, an ambiguous ticket, someone else holding the
work, the usage limit, an approval, or a person's own action. The type
that writes the status takes one, and the reason is kept on the wait.
supervisor::hand_back_for is the one reading of a stop.

Every former hand-back ending now finishes through supervisor::end:
- a stop after the work ships: tasks left are deferred with why on the
  checklist, the pull request gets a Deferred section, and the run goes on
  to CI and the ready decision;
- CI give-ups revert to the last green head, else take out the last planned
  task, defer it and let CI decide again; only when nothing can come out
  does the run end failed with what fails;
- own-review, planned-work and guard stops finish on their pull request
  (failed when its CI is red); held drafts on finished runs stay recorded
  without turning the run into a wait.

A step that changed nothing climbs a ladder instead of stopping: one task,
fresh context with edits in place, a re-split, the strongest model, defer
the task (non-core after three), then ship; near 85% of the spend ceiling
it ships. Own-review rounds extend while they fix things, up to twice the
cap. Errors after the work get one fresh step, the step-limit continuation
covers every pass after the work, and a reply that spent its whole output
thinking is taken again with less thinking instead of read as the answer.

Tests: the supervisor's rules over every combination, a replay of 217
historical stuck-run shapes (invented names) asserting no run waits unless
its blocker is on the list, and a source scan that fails when an ending
goes around the supervisor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant